package java8_16;

/**
 * @author oldliu
 * @since 1.0
 */

import java.util.Scanner;

public class DingDanLianMeng {
    public static void main(String[] args) {
        Scanner aa = new Scanner(System.in);
        int[] ae = new int[5];//点赞量数组
        String[] ab = new String[]{"回锅肉", "炒鸡蛋", "辣椒肉", "红烧肉", "烩青菜"};
        int[] ac = new int[]{15, 10, 13, 26, 8};//价格数组
        int[] ad = new int[5];//总价数组
        String[] af = new String[5];//订餐人姓名数组
        int[] ag = new int[5];//送餐时间数组
        String[] ah = new String[5];//地址数组
        String[] ai = new String[5];//购买菜数组
        int state[] = new int[5];//订单状态
        boolean aj = false;
        int bbb = 0;
        System.out.println("欢迎进入\"吃货联盟\"订单系统");
        System.out.println("********************");
        //a b c d e f g h i j k
        for (; ; ) {
            System.out.println("1.我要订餐");
            System.out.println("2.查看餐袋");
            System.out.println("3.签收订单");
            System.out.println("4.删除订单");
            System.out.println("5.我要点赞");
            System.out.println("6.退出系统");
            System.out.println("********************");
            System.out.println("请选择");
            int aaa = 0;
            int a = aa.nextInt();
            if (a == 1) {
                System.out.println("****我要订餐****");
                System.out.println("序号" + "\t\t菜名" + "\t\t单价" + "\t\t点赞数");
                for (int b = 0; b < ae.length; b++) {
                    System.out.println((b + 1) + "\t\t" + ab[b] + "\t\t" + ac[b] + "\t\t" + ae[b]);
                }
                for (; ; ) {
                    int bc;
                    System.out.println("输入订餐人姓名：");
                    String h = aa.next();
                    af[bbb] = h;
                    for (; ; ) {
                        System.out.println("输入你要点的菜品编号");
                        int c = aa.nextInt();
                        if (c >= 1 && c <= 5) {
                            bc = c;
                            ai[bbb] = ab[c - 1];
                            break;
                        } else {
                            System.out.println("没有该菜系哦");
                        }
                    }
                    System.out.println("选择输入的份数");
                    int d = aa.nextInt();
                    aaa = ac[bc - 1] * d;//总金额
                    ad[bbb] = aaa;
                    System.out.println("输入送餐时间（12点至20点）");
                    for (; ; ) {
                        int f = aa.nextInt();
                        if (f >= 12 && f <= 20) {
                            ag[bbb] = f;
                            break;
                        }
                        if (f < 11 || f > 21) {
                            System.out.println("输入错误，这时间不配送");
                        }
                    }
                    System.out.println("送餐地址");
                    String g = aa.next();
                    ah[bbb] = g;
                    System.out.println("丁餐成功！");
                    System.out.println("您的订单是：" + (ab[bc - 1]) + d + "份");
                    System.out.println("送餐时间是：" + ag[bbb]);
                    if (aaa < 50) {
                        aaa += 5;
                        System.out.println("餐费是：" + (aaa - 5) + "\t送餐费" + 5 + "\t总计" + (aaa));
                    } else {
                        System.out.println("餐费是：" + aaa + "\t送餐费" + 0 + "\t总记" + aaa);
                    }
                    state[bbb] = 0;
                    bbb++;
                    System.out.println("退出输入0继续按1");
                    String ddd = aa.next();
                    if (ddd.equals("0")) {
                        break;
                    }
                }
            }
            if (a == 2) {
                for (; ; ) {
                    System.out.println("****查看餐袋****");
                    System.out.println("序号" + "\t订餐人" + "\t餐品信息" + "\t送餐时间" + "\t送餐地址" + "\t总金额" + "\t订单状态");
                    if (bbb == 0) {
                        System.out.println("您的餐袋是空的呢!");
                    }
                    for (int b = 0; b < bbb; b++) {
                        System.out.print((b + 1) + "\t" + af[b] + "\t" + ai[b] + "\t" + ag[b] + "时\t" + ah[b] + "\t" + ad[b] + "元\t");

                        if (state[b] == 0) {
                            System.out.println("\t已预定");
                        } else if (state[b] == 1) {
                            System.out.println("\t已完成");
                        } else if (state[b] == 3) {
                            System.out.println("\t已删除");
                        }
                    }
                    System.out.println("退出输入0继续按1");
                    String eee = aa.next();
                    if (eee.equals("0")) {
                        break;
                    }
                }
            }
            if (a == 3) {
                for (; ; ) {
                    System.out.println("****签收订单****");
                    System.out.println("选择要签收的订单");
                    int i = aa.nextInt();
                    if (i <= bbb && bbb != 0) {
                        state[i - 1] = 1;
                        System.out.println("签收成功");
                    }
                    if (i > bbb) {
                        System.out.println("抱歉,没找到该订单!");
                        break;
                    }

                    System.out.println("退出输入0继续按1");
                    String fff = aa.next();
                    if (fff.equals("0")) {
                        break;
                    }
                }
            }
            if (a == 4) {
                for (; ; ) {
                    System.out.println("****删除订单****");
                    System.out.println("输入要删除的订单：");
                    int j = aa.nextInt();
                    if (j <= 0 || j >= 6) {
                        System.out.println("没有这个订单号哦");
                    } else {
                        if (j <= bbb) {
                            if (state[j - 1] != 1) {
                                for (int k = j - 1; k < af.length - 1; k++) {
                                    ad[k] = ad[k + 1];
                                    ag[k] = ag[k + 1];
                                    ah[k] = ah[k + 1];
                                    ai[k] = ai[k + 1];
                                    af[k] = af[k + 1];
                                    state[k] = state[k + 1];
                                }
                                ad[ai.length - 1] = 0;
                                ag[ai.length - 1] = 0;
                                ah[ai.length - 1] = null;
                                ai[ai.length - 1] = null;
                                af[ai.length - 1] = null;
                                state[state.length - 1] = 3;
                                System.out.println("删除成功");
                            }
                        }
                        if (j > bbb) {
                            System.out.println("没找到该订单");
                        }
                        if (state[j - 1] == 1) {
                            System.out.println("该订单已完成，不可删除。");
                        }
                        System.out.println("退出输入0继续按1");
                        String ggg = aa.next();
                        if (ggg.equals("0")) {
                            break;
                        }
                    }
                }
            }
            if (a == 5) {
                System.out.println("****我要点赞****");
                for (; ; ) {
                    int cd = 0;
                    for (String ca : ab) {
                        cd++;
                        System.out.println((cd) + ":" + ca);
                    }
                    System.out.println("输入要点赞的序号：");
                    int bac = aa.nextInt();
                    ae[bac - 1] += 1;
                    System.out.println("退出输入0继续按1");
                    String hhh = aa.next();
                    if (hhh.equals("0")) {
                        break;
                    }
                }

            }
            if (a == 6) {
                System.out.println("欢迎下次光临！！");
                break;
            }
            if (a <= 0 || a >= 7) {
                System.out.println("没有该选项。");
                System.out.println("********************");
            }


        }


    }
}
